import * as service from "../services/mainpage";
export default {
  namespace: "mainpage",
  state: {
    showPersonal: false
  },
  subscriptions: {
    setup({ dispatch, history }) {
      return history.listen(({ pathname, query }) => {
        if (pathname === "/mainpage") {
          dispatch({
            type: "fetch"
          });
        }
      });
    }
  },
  effects: {
    *fetch({ payload }, { call, put }) {
      yield put({
        type: "save",
        payload: {
          text: "page init"
        }
      });
    },
    *onPersonal({ payload }, { call, put }) {
        console.log(payload);
        
      yield put({
        type: "save",
        payload: {
            showPersonal: payload.showPersonal
        }
      });
    }
  },
  reducers: {
    save(state, action) {
      return { ...state, ...action.payload };
    }
  }
};
